package com.leo.component;

import com.almasb.fxgl.entity.component.Component;
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.HitBox;
import javafx.geometry.Point2D;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

/**
 * @Author: wangss
 * @CreateTime: 2023-06-07  12:38
 * @Description: 目标
 */
public class TargetComponent extends Component {

    public TargetComponent() {
    }

    @Override
    public void onAdded() {
        Rectangle rectangle1 = new Rectangle(8, 20, Color.YELLOW);
        Rectangle rectangle2 = new Rectangle(8, 40, Color.BLUE);
        Rectangle rectangle3 = new Rectangle(8, 60, Color.WHITE);

        entity.getBoundingBoxComponent().addHitBox(new HitBox("high", new Point2D(0, 20), BoundingShape.box(8, 20)));
        entity.getBoundingBoxComponent().addHitBox(new HitBox("middle", new Point2D(8, 10), BoundingShape.box(8, 40)));
        entity.getBoundingBoxComponent().addHitBox(new HitBox("low", new Point2D(16, 0), BoundingShape.box(8, 60)));

        entity.getViewComponent().addChild(rectangle1);
        rectangle1.setTranslateY(20);
        entity.getViewComponent().addChild(rectangle2);
        rectangle2.setTranslateX(8);
        rectangle2.setTranslateY(10);
        entity.getViewComponent().addChild(rectangle3);
        rectangle3.setTranslateX(16);

    }
}
